<?php
/*
    Author : Novi Setiani
*/
class Notifikasikegiatan extends CI_Model{
    public function add($activityID, $userID, $notification){
        $this->db->insert('notifikasikegiatan', array('activityID'=>$activityID, 'userID'=>$userID, 'notification'=>$notification));
    }
    
    public function delete($activityID, $userID){
        $this->db->delete('notifikasikegiatan',array('activityID'=>$activityID, 'userID'=>$userID));
    }

    public function setStatus($userID){
        $this->db->update('notifikasikegiatan', array ('status' => 1), "userID = '$userID'");
    }
    public function getUnreaded($userID){
        $q = $this->db->get_where('notifikasikegiatan',array('userID'=>$userID, 'status'=>0));
        $notif['count'] = $q->num_rows();
        if($q->num_rows() > 0){
            $i = 0;
            foreach($q->result() as $row){
                $notif['notifikasi'][$i]['message'] = $row->notification;
                $notif['notifikasi'][$i]['activity_id'] = $row->activityID;
                $i++;
            }
        }
        return $notif;
    }
}
?>